package cn.tedu.boot06.controller;

import cn.tedu.boot06.entity.Product;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AxiosController {
    @RequestMapping("/helloAxios")
    public String helloAxios(){

        return "测试成功!";
    }

    @RequestMapping("/p1")
    public String p1(String name,int age){
        return name+":"+age;
    }


    //当客户端是post请求并且提交的是JS对象时使用@RequestBody注解
    //否则接收到的是null
    @RequestMapping("/p2")
    public String p2(@RequestBody Product product){

        return product.toString();
    }


}
